﻿using System;

namespace TypeBuilderFx.Core
{
    /// <summary>Represents a cache of type emitters.</summary>
    /// <remarks>
    /// <para>Must be safe to use from multiple threads at the same time.</para>
    /// <para>
    /// Having an interface to represent caches will allow different implementations, including more parallelizable
    /// implementations.
    /// </para>
    /// </remarks>
    public interface ITypeEmitterCache : IDisposable
    {
        /// <summary>
        /// Returns a factory created by a type emitter.  Factories are cached for the duration of the application domain.
        /// </summary>
        /// <remarks>The type of the returned factory depends on the type emitter options.</remarks>
        /// <typeparam name="T_OPTIONS"></typeparam>
        /// <param name="typeEmitter"></param>
        /// <returns></returns>
        object GetFactory<T_OPTIONS>(TypeEmitterBase<T_OPTIONS> typeEmitter)
            where T_OPTIONS : TypeEmitterOptions;
    }
}